//
// NeL - bindings
// Copyright (C) 2010 Naush
//
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU Affero General Public License as
//published by the Free Software Foundation, either version 3 of the
//License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU Affero General Public License for more details.
//
//You should have received a copy of the GNU Affero General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.
package org.ryzom.nel.misc;

public class CPlane {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CPlane(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CPlane obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nelmiscJNI.delete_CPlane(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public void setA(float value) {
    nelmiscJNI.CPlane_a_set(swigCPtr, this, value);
  }

  public float getA() {
    return nelmiscJNI.CPlane_a_get(swigCPtr, this);
  }

  public void setB(float value) {
    nelmiscJNI.CPlane_b_set(swigCPtr, this, value);
  }

  public float getB() {
    return nelmiscJNI.CPlane_b_get(swigCPtr, this);
  }

  public void setC(float value) {
    nelmiscJNI.CPlane_c_set(swigCPtr, this, value);
  }

  public float getC() {
    return nelmiscJNI.CPlane_c_get(swigCPtr, this);
  }

  public void setD(float value) {
    nelmiscJNI.CPlane_d_set(swigCPtr, this, value);
  }

  public float getD() {
    return nelmiscJNI.CPlane_d_get(swigCPtr, this);
  }

  public CPlane() {
    this(nelmiscJNI.new_CPlane__SWIG_0(), true);
  }

  public CPlane(float _a, float _b, float _c, float _d) {
    this(nelmiscJNI.new_CPlane__SWIG_1(_a, _b, _c, _d), true);
  }

  public CPlane(CPlane v) {
    this(nelmiscJNI.new_CPlane__SWIG_2(CPlane.getCPtr(v), v), true);
  }

  public void make(CVector normal, CVector pos) {
    nelmiscJNI.CPlane_make__SWIG_0(swigCPtr, this, CVector.getCPtr(normal), normal, CVector.getCPtr(pos), pos);
  }

  public void make(CVector p0, CVector p1, CVector p2) {
    nelmiscJNI.CPlane_make__SWIG_1(swigCPtr, this, CVector.getCPtr(p0), p0, CVector.getCPtr(p1), p1, CVector.getCPtr(p2), p2);
  }

  public CVector getNormal() {
    return new CVector(nelmiscJNI.CPlane_getNormal(swigCPtr, this), true);
  }

  public void normalize() {
    nelmiscJNI.CPlane_normalize(swigCPtr, this);
  }

  public CPlane normed() {
    return new CPlane(nelmiscJNI.CPlane_normed(swigCPtr, this), true);
  }

  public float distance(CVector p) {
    return nelmiscJNI.CPlane_distance(swigCPtr, this, CVector.getCPtr(p), p);
  }

  public float mul(CVector p) {
    return nelmiscJNI.CPlane_mul(swigCPtr, this, CVector.getCPtr(p), p);
  }

  public CVector intersect(CVector p0, CVector p1) {
    return new CVector(nelmiscJNI.CPlane_intersect(swigCPtr, this, CVector.getCPtr(p0), p0, CVector.getCPtr(p1), p1), true);
  }

  public CVector project(CVector p0) {
    return new CVector(nelmiscJNI.CPlane_project(swigCPtr, this, CVector.getCPtr(p0), p0), true);
  }

  public boolean clipSegmentBack(CVector p0, CVector p1) {
    return nelmiscJNI.CPlane_clipSegmentBack(swigCPtr, this, CVector.getCPtr(p0), p0, CVector.getCPtr(p1), p1);
  }

  public boolean clipSegmentFront(CVector p0, CVector p1) {
    return nelmiscJNI.CPlane_clipSegmentFront(swigCPtr, this, CVector.getCPtr(p0), p0, CVector.getCPtr(p1), p1);
  }

  public int clipPolygonBack(CVector in, CVector out, int nIn) {
    return nelmiscJNI.CPlane_clipPolygonBack__SWIG_0(swigCPtr, this, CVector.getCPtr(in), in, CVector.getCPtr(out), out, nIn);
  }

  public int clipPolygonBack(CVector in, CUV inUV, CVector out, CUV outUV, int nIn) {
    return nelmiscJNI.CPlane_clipPolygonBack__SWIG_1(swigCPtr, this, CVector.getCPtr(in), in, CUV.getCPtr(inUV), inUV, CVector.getCPtr(out), out, CUV.getCPtr(outUV), outUV, nIn);
  }

  public int clipPolygonFront(CVector in, CVector out, int nIn) {
    return nelmiscJNI.CPlane_clipPolygonFront(swigCPtr, this, CVector.getCPtr(in), in, CVector.getCPtr(out), out, nIn);
  }

  public CPlane inverted() {
    return new CPlane(nelmiscJNI.CPlane_inverted(swigCPtr, this), true);
  }

  public void invert() {
    nelmiscJNI.CPlane_invert(swigCPtr, this);
  }

  public void serial(IStream f) {
    nelmiscJNI.CPlane_serial(swigCPtr, this, IStream.getCPtr(f), f);
  }

  public boolean isEqual(CPlane o) {
    return nelmiscJNI.CPlane_isEqual(swigCPtr, this, CPlane.getCPtr(o), o);
  }

}
